package com.qfjy.homework.lwl;

public class Proxy implements Subject{
    private RealSubject realSubject;

    public Proxy() {
        realSubject = new RealSubject();
    }

    @Override
    public void doSomething() {
        // 在访问目标对象之前可以执行一些额外的操作
        System.out.println("Proxy is doing something before calling the real object.");

        // 调用真实的目标对象的方法
        realSubject.doSomething();

        // 在访问目标对象之后可以执行一些额外的操作
        System.out.println("Proxy is doing something after calling the real object.");
    }
}
